package myAsm;

import java.util.Map;

import javax.persistence.*;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;


@Entity
@DiscriminatorValue("INSN_LABELNODE")
public class MyLabelNode extends MyAbstractInsnNode {

	@Transient
	private Label label;
	
	
	public MyLabelNode() {
		super(-1);
	}
	
	public MyLabelNode(int opcode) {
		super(-1);
	}
	
	public MyLabelNode(final Label label) {
        super(-1);
        this.label = label;
    }

    public int getType() {
        return LABEL;
    }

    public Label getLabel() {
        if (label == null) {
            label = new Label();
        }
        return label;
    }

    public void accept(final MethodVisitor cv) {
        cv.visitLabel(getLabel());
    }

    public MyAbstractInsnNode clone(final Map labels) {
        return (MyLabelNode) labels.get(this);
    }

    public void resetLabel() {
        label = null;
    }
}